package org.longsheng.learnspringboot.controller;

import org.longsheng.learnspringboot.config.AppConfig;
import org.longsheng.learnspringboot.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;

/**
 * @author DingQiao
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private AppConfig appConfig;

    @RequestMapping("/")
    public String hello(Locale locale, Model model) {

        return "Hello World";
    }

    @RequestMapping("/user")
    public User getUser() {
        System.out.printf("标题：%s；描述：%s%n", appConfig.getTitle(), appConfig.getDescription());

        User user = new User();
        user.setUserName("小明");
        user.setPassWord("xxxx");
        return user;
    }
}
